package com.fhz.day004;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ObservableArrayMap;

import com.fhz.day004.databinding.ActivityMainBinding;

public class MainActivity extends AppCompatActivity {
    User user;
    Student student;
    ObservableArrayMap<String, Object> map;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        setContentView(R.layout.activity_main);
        ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
        user = new User();
        user.setName("小明");


        //课观察字段
        user.address.set("天津");
        binding.setUser(user);
        binding.setActivity(this);

        //可观察的集合
        map = new ObservableArrayMap<>();
        map.put("name","小明");
        map.put("age",18);

        binding.setMap(map);


        //课观察对象
        student = new Student();
        student.setFirstName("dada名");

        binding.setStudent(student);


    }

    public void click(){
        user.setName("大明");
        user.address.set("北京");
        map.put("name","xiaoxiao明");
        student.setFirstName("大大明");
    }
}